import sys

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QLabel

from UI.bilibili.BBDown_GUI import FormMain
from UI.youtube.YouTuBe_UI import YouTuBeMainWindow


class VideoDown(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('视频下载器')

        # 获取屏幕尺寸
        screen_size = QApplication.primaryScreen().size()
        # 计算窗口的初始位置和大小
        window_size = (700, 400)  # 自定义窗口大小
        window_position = ((screen_size.width() - window_size[0]) // 2, (screen_size.height() - window_size[1]) // 2)
        self.setGeometry(window_position[0], window_position[1], window_size[0], window_size[1])

        # 初始化界面
        self.bilibili = FormMain()
        self.youtube = YouTuBeMainWindow()

        # 创建布局
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.button = QPushButton('下载B站视频')
        self.button.clicked.connect(self.onBilibiliButtonClick)
        self.button.setGeometry(50, 50, 100, 50)
        # 按钮添加到布局组件
        self.layout.addWidget(self.button)

        self.button2 = QPushButton('下载YouTuBu视频')
        self.button2.clicked.connect(self.onYouTuBuButtonClick)
        self.button2.setGeometry(50, 50, 100, 50)
        # 按钮添加到布局组件
        self.layout.addWidget(self.button2)

    def onBilibiliButtonClick(self):
        self.close()
        self.bilibili.show()

    def onYouTuBuButtonClick(self):
        self.close()
        self.youtube.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = VideoDown()
    window.show()
    sys.exit(app.exec_())
